package tgc.edu.yzy.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Transient;

import com.fasterxml.jackson.annotation.JsonIgnore;

import tgc.edu.yzy.custom.CommonEntityId;
@Entity
public class Dapa extends CommonEntityId{
	private String name;//必须要
	private Integer checked;//不知道是啥
	private String icon;//不用管
	@JsonIgnore
	private Dapa parent;
	@JsonIgnore
	private List<Dapa> children=new ArrayList<>();
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Integer getChecked() {
		return checked;
	}
	public void setChecked(Integer checked) {
		this.checked = checked;
	}
	public String getIcon() {
		return icon;
	}
	public void setIcon(String icon) {
		this.icon = icon;
	}
	@ManyToOne
	public Dapa getParent() {
		return parent;
	}
	public void setParent(Dapa parent) {
		this.parent = parent;
	}
	@OneToMany(cascade=CascadeType.ALL,mappedBy="parent")
	public List<Dapa> getChildren() {
		return children;
	}
	public void setChildren(List<Dapa> children) {
		this.children = children;
	}
	@Transient
	public Integer getpId() {
		return parent==null?null:parent.getId();
	}
	@Transient
	public Boolean getIsParent() {
		return children.isEmpty()?false:true;
	}
	
}
